package com.jprocms.module.cms.api.dto;

import com.mzt.logapi.starter.annotation.DiffLogField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class AdminIpConfig implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 是否开启后台访问IP限制 1开启 0 关闭
     */
    @DiffLogField(name = "是否开启后台访问IP限制")
    private int limitOpen = 0;
    /**
     * 访问限制固定的 IP
     */
    @DiffLogField(name = "访问限制固定的")
    private List<String> ips = new ArrayList<>();
    /**
     * 访问后台限制 ip区间
     */
    @DiffLogField(name = "访问后台限制")
    private List<IpRangeVO> ipRanges = new ArrayList<>();


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AdminIpConfig that = (AdminIpConfig) o;
        return limitOpen == that.limitOpen && Objects.equals(ips, that.ips) && Objects.equals(ipRanges, that.ipRanges);
    }

    @Override
    public int hashCode() {
        return Objects.hash(limitOpen, ips, ipRanges);
    }
}
